package drds.binlog.binlog_event.event;

import drds.binlog.binlog_event.LogByteBlock;
import drds.binlog.common.Authors;
import drds.common.Author;
import lombok.Getter;
import lombok.Setter;

/**
 * mariadb的ANNOTATE_ROWS_EVENT类型
 */
@Author(name = Authors.LI_YANG)
public class AnnotateRowsEvent extends IgnorableLogEvent
{
    @Setter
    @Getter
    private String rowsQuery;

    public AnnotateRowsEvent(LogHeader logHeader, LogByteBlock logByteBlock, FormatDescriptionLogEvent formatDescriptionLogEvent)
    {
        super(logHeader, logByteBlock, formatDescriptionLogEvent);

        final int commonHeaderLength = formatDescriptionLogEvent.getCommonHeaderLength();
        final int postHeaderLength = formatDescriptionLogEvent.getPostHeaderLengths()[logHeader.getLogType() - 1];

        int offset = commonHeaderLength + postHeaderLength;
        int len = logByteBlock.limit() - offset;
        rowsQuery = logByteBlock.getFullString(offset, len, LogByteBlock.ISO_8859_1);
    }

}
